package com.guaju.yueshangLife.net;

import com.guaju.yueshangLife.base.GoodsDetail;
import com.guaju.yueshangLife.bean.AboutUsBean;
import com.guaju.yueshangLife.bean.AddAddressBean;
import com.guaju.yueshangLife.bean.AddComment;
import com.guaju.yueshangLife.bean.AdviceBean;
import com.guaju.yueshangLife.bean.AlipayBean;
import com.guaju.yueshangLife.bean.CartBean;
import com.guaju.yueshangLife.bean.CartTotal;
import com.guaju.yueshangLife.bean.CategoryTotal;
import com.guaju.yueshangLife.bean.CommentsBean;
import com.guaju.yueshangLife.bean.CreateOrderBean;
import com.guaju.yueshangLife.bean.DelResultBean;
import com.guaju.yueshangLife.bean.GoodsListTotal;
import com.guaju.yueshangLife.bean.HomeTotal;
import com.guaju.yueshangLife.bean.MeBean;
import com.guaju.yueshangLife.bean.MeDetailBean;
import com.guaju.yueshangLife.bean.MeOrder;
import com.guaju.yueshangLife.bean.MePermissionBean;
import com.guaju.yueshangLife.bean.MePocketBean;
import com.guaju.yueshangLife.bean.MineOrder;
import com.guaju.yueshangLife.bean.MyAddressBean;
import com.guaju.yueshangLife.bean.Offline;
import com.guaju.yueshangLife.bean.OrderDeleteBean;
import com.guaju.yueshangLife.bean.OrderDetailBean;
import com.guaju.yueshangLife.bean.PicBean;
import com.guaju.yueshangLife.bean.PocketLogsBean;
import com.guaju.yueshangLife.bean.ReceiveGoods;
import com.guaju.yueshangLife.bean.SetDefaultBean;
import com.guaju.yueshangLife.bean.UpdateMineInfo;

import java.util.List;

import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import rx.Observable;

public interface ApiService {

    //TODO:baseUrl
//    String NEW_HOST = "http://api.shop.yueshangfushi.com";
    String NEW_HOST = "http://larashop.nfangxu.cn";//测试环境
    //    yl.nfangxu.com
    String NEW_HOST1 = "http://api.shop.yueshangfushi.com";//测试环境
    String API_SERVER_URL = NEW_HOST;//接口版本
    String API_SERVER_URL1 = NEW_HOST1;//接口版本
    //TODO:具体业务接口
    String URL_SMS_SEND_LOGIN_CODE = "api/code/login"; //登录发送短信
    String URL_SMS_SEND_REGIST_CODE = "api/code/register"; //注册发送短信
    String URL_SMS_VERIFY_CODE = "api/code/verify"; //验证短信
    String URL_CATEGORY = "/api/category"; //分类
    String URL_HOME = "/api/home"; //首页
    String URL_PRODUCTS = "/api/products"; //产品

    String URL_PRODUCTS_DETAIL = "/api/product/show"; //产品详情
    String URL_SET_PASSWORD = "/api/password"; //设置密码
    String URL_LOGOUT = "/api/logout"; //退出登录
    String URL_ME = "/api/me"; //我的
    String URL_ME_DETAIL = "/api/me/detail"; //我的详细信息
    String URL_ME_PERMISSION = "/api/me/permission"; //我的会员权限
    String URL_ME_POCKET = "/api/me/pocket"; //我的钱包
    String URL_ME_POCKET_LOGS = "/api/me/pocket/logs"; //我的钱包


    String URL_CART = "/api/cart"; //购物车
    String URL_ADD_CART = "/api/cart/store"; //添加进入购物车
    String URL_UPDATE = "/api/cart/update"; //更新购物车中商品数量
    String URL_COUPON = "/api/products/coupon"; //优惠商品
    String URL_LOGIN = "/api/login"; //账号密码登录
    String URL_ORDER = "/api/order/prepare"; //订单
    String SMS_KEY = "yslife";
    String URL_ABOUT = "/api/about";
    String URL_ADVICE = "/api/suggestion";
    String URL_DEL_FROM_CART = "/api/cart/delete";
    String URL_CREATE_ORDER = "/api/order/store";

    String URL_PREPARE_ORDER = "/api/order/prepare";

    String URL_ADDRESS = "/api/address";
    String URL_ME_ADDRESS = "/api/me/address";
    String URL_ME_ADDRESS_SETDEFAULT = "/api/me/address/default";
    String URL_ME_ORDER = "/api/order";
    String URL_ORDER_DETAIL = "/api/order/show";


    String URL_ORDER_CANCEL = "/api/order/cancel";

    String URL_COMMENTS = "/api/comments";
    String URL_ADD_COMMENTS = "/api/comments/store";

    String URL_ORDER_DELETE = "/api/order/delete";
    /**
     * 确认收货
     */
    String URL_ORDER_RECEIVE = "/api/order/receive";
    /**
     * 支付
     */
    String URL_ORDER_PAY = "/api/pay/order";


    String URL_PIC = "/api/upload/config";
    String URL_UPDATE_MINE_INFO = "/api/me/update";

    String URL_SAVE_FAV = "/collections/attach";
    String URL_DEL_FAV = "/collections/detach";
    String URL_OFFLINE = "/api/offline";


    //TODO:具体业务方法

    @FormUrlEncoded
    @POST(URL_SMS_SEND_LOGIN_CODE)
    Observable<String> saveFav(@Field("product_id") int product_id);

    /**
     * 传 0 表示清空
     *
     * @param product_id
     * @return
     */
    @FormUrlEncoded
    @POST(URL_SMS_SEND_LOGIN_CODE)
    Observable<String> delFav(@Field("product_id") int product_id);

    @FormUrlEncoded
    @POST(URL_SMS_SEND_LOGIN_CODE)
    Observable<String> loginSmsCode(@Field("mobile") String mobile);

    @FormUrlEncoded
    @POST(URL_SMS_SEND_REGIST_CODE)
    Observable<String> registSmsCode(@Field("mobile") String mobile);

    @FormUrlEncoded
    @POST(URL_SMS_VERIFY_CODE)
    Observable<String> verifyCode(@Field("verify_key") String verify_key, @Field("verify_code") String verify_code);

    @POST(URL_CATEGORY)
    Observable<CategoryTotal> category();

    @POST(URL_HOME)
    Observable<HomeTotal> home();

    @FormUrlEncoded
    @POST(URL_PRODUCTS)
    Call<GoodsListTotal> goods(@Field("page") int page, @Field("limit") int limit, @Field("category") String category, @Field("keyword") String keyword);

    @FormUrlEncoded
    @POST(URL_PRODUCTS)
    Call<GoodsListTotal> goods(@Field("page") int page, @Field("limit") int limit, @Field("category") String category);

    @FormUrlEncoded
    @POST(URL_PRODUCTS)
    Call<GoodsListTotal> goodsSortBySales(@Field("page") int page, @Field("category") String category, @Field("sales") String sales);

    @FormUrlEncoded
    @POST(URL_PRODUCTS)
    Call<GoodsListTotal> goodsSortByPrice(@Field("page") int page, @Field("category") String category, @Field("price") String price);


    @FormUrlEncoded
    @POST(URL_PRODUCTS)
    Call<GoodsListTotal> goodsSortByPublish(@Field("page") int page, @Field("category") String category, @Field("publish") String publish);

    @FormUrlEncoded
    @POST(URL_PRODUCTS)
    Call<GoodsListTotal> goods(@Field("page") int page, @Field("category") String category);


    @FormUrlEncoded
    @POST(URL_PRODUCTS)
    Call<GoodsListTotal> goodsSortBySales(@Field("page") int page, @Field("sales") String sales);

    @FormUrlEncoded
    @POST(URL_PRODUCTS)
    Call<GoodsListTotal> goodsSortByPrice(@Field("page") int page, @Field("price") String price);


    @FormUrlEncoded
    @POST(URL_PRODUCTS)
    Call<GoodsListTotal> goodsSortByPublish(@Field("page") int page, @Field("publish") String publish);


    @FormUrlEncoded
    @POST(URL_PRODUCTS)
    Call<GoodsListTotal> goods(@Field("page") int page);

    @FormUrlEncoded
    @POST(URL_PRODUCTS_DETAIL)
    Observable<GoodsDetail> goodsDetail(@Field("id") String id);

    @FormUrlEncoded
    @POST(URL_PRODUCTS_DETAIL)
    Observable<String> goodsDetailString(@Field("id") String id);

    @FormUrlEncoded
    @POST(URL_SET_PASSWORD)
    Observable<String> setPassword(@Field("password") String password, @Field("password_confirm") String password_confirm);

    @POST(URL_LOGOUT)
    Observable<String> logOut();

    @POST(URL_ME)
    Observable<MeBean> me();

    @POST(URL_ME_DETAIL)
    Observable<MeDetailBean> meDetail();

    @POST(URL_ME_PERMISSION)
    Observable<MePermissionBean> mePermission();

    @POST(URL_ME_POCKET)
    Observable<MePocketBean> mePocket();


    @FormUrlEncoded
    @POST(URL_ME_POCKET_LOGS)
    Call<PocketLogsBean> pocketLogs(@Field("page") int page, @Field("limit") int limit);


    @POST(URL_CART)
    Observable<CartBean> cart();

    @POST(URL_CART)
    Observable<String> cartString();

    @FormUrlEncoded
    @POST(URL_ADD_CART)
    Observable<String> addCart(@Field("id") int id, @Field("sku") int sku_id, @Field("number") String number);

    @FormUrlEncoded
    @POST(URL_LOGIN)
    Observable<String> login(@Field("mobile") String mobile, @Field("password") String password);

    @FormUrlEncoded
    @POST(URL_ORDER)
    Observable<String> order(@Field("ids") String ids);

    @POST(URL_ABOUT)
    Observable<AboutUsBean> about();

    @FormUrlEncoded
    @POST(URL_ADVICE)
    Observable<AdviceBean> advice(@Field("content") String content, @Field("type") int type, @Field("mobile") String mobile, @Field("email") String email, @Field("third_party") String third_party);

    @FormUrlEncoded
    @POST(URL_DEL_FROM_CART)
    Observable<DelResultBean> delFromCart(@Field("ids") String ids);

    @FormUrlEncoded
    @POST(URL_UPDATE)
    Observable<String> updateCartGoods(@Field("id") int id, @Field("number") int number);

    @FormUrlEncoded
    @POST(URL_ADDRESS)
    Observable<String> address(@Field("code") int code);

    @POST(URL_ADDRESS)
    Observable<String> address();


    @GET(URL_ME_ADDRESS)
    Observable<MyAddressBean> meAddress();

    @FormUrlEncoded
    @POST(URL_ME_ADDRESS)
    Observable<AddAddressBean> addAddress(@Field("province") int province, @Field("city") int city, @Field("district") int district, @Field("address") String address, @Field("contact_name") String contact_name, @Field("contact_phone") String contact_phone, @Field("is_default") int is_default);

    @POST(URL_COUPON)
    Observable<String> coupon();

    @FormUrlEncoded
    @POST(URL_ME_ADDRESS_SETDEFAULT)
    Observable<SetDefaultBean> setDefaultAddress(@Field("address") int address);

    @FormUrlEncoded
    @POST(URL_CREATE_ORDER)
    Observable<CreateOrderBean> createOrder(@Field("ids") String ids, @Field("remark") String remark, @Field("address") int address, @Field("payment") int payment, @Field("postage") String postage);


    @FormUrlEncoded
    @POST(URL_PREPARE_ORDER)
    Observable<String> prepareOrder(@Field("ids") String ids);

    @FormUrlEncoded
    @POST(URL_ME_ORDER)
    Observable<MineOrder> meOrder(@Field("status") String status, @Field("page") int page, @Field("limit") int limit);

    @FormUrlEncoded
    @POST(URL_ME_ORDER)
    Call<MineOrder> meOrderCall(@Field("status") String status, @Field("page") int page, @Field("limit") int limit);


    @FormUrlEncoded
    @POST(URL_COMMENTS)
    Call<CommentsBean> comments(@Field("product_id") String product_id, @Field("filter") int filter, @Field("page") int page, @Field("limit") int limit);

    @FormUrlEncoded
    @POST(URL_ORDER_DELETE)
    Observable<OrderDeleteBean> deleteOrder(@Field("id") int id);

    @FormUrlEncoded
    @POST(URL_ORDER_RECEIVE)
    Observable<ReceiveGoods> receiveOrder(@Field("id") int id);

    @FormUrlEncoded
    @POST(URL_ORDER_DETAIL)
    Observable<OrderDetailBean> orderDetail(@Field("id") int id);

    @FormUrlEncoded
    @POST(URL_ORDER_CANCEL)
    Observable<String> cancleOrder(@Field("id") int id, @Field("reason") String reason);

    @FormUrlEncoded
    @POST(URL_UPDATE_MINE_INFO)
    Observable<UpdateMineInfo> updateMyInfo(@Field("avatar") String avatar, @Field("username") String username, @Field("summary") String summary, @Field("sex") String sex);

    @FormUrlEncoded
    @POST(URL_UPDATE_MINE_INFO)
    Observable<UpdateMineInfo> updateMyInfoAvatar(@Field("avatar") String avatar);

    @FormUrlEncoded
    @POST(URL_UPDATE_MINE_INFO)
    Observable<UpdateMineInfo> updateMyInfo(@Field("username") String username, @Field("summary") String summary, @Field("sex") String sex);

    @FormUrlEncoded
    @POST(URL_UPDATE_MINE_INFO)
    Observable<UpdateMineInfo> updateMyInfoSex(@Field("sex") String sex);

    @FormUrlEncoded
    @POST(URL_UPDATE_MINE_INFO)
    Observable<UpdateMineInfo> updateMyInfoSummary(@Field("summary") String summary);

    @FormUrlEncoded
    @POST(URL_UPDATE_MINE_INFO)
    Observable<UpdateMineInfo> updateMyInfoUsername(@Field("username") String username);
    @FormUrlEncoded
    @POST(URL_ADD_COMMENTS)
    Observable<AddComment> addComments(@Field("order_id") String order_id, @Field("item_id") String item_id, @Field("content") String content, @Field("score") String score, @Field("images") String images);

    @FormUrlEncoded
    @POST(URL_ADD_COMMENTS)
    Observable<String> addComments(@Field("order_id") String order_id, @Field("item_id") String item_id, @Field("content") String content, @Field("score") String score);

    @FormUrlEncoded
    @POST(URL_ORDER_PAY)
    Observable<AlipayBean> pay(@Field("order_id") int order_id, @Field("password") String password, @Field("payment") int payment);

    @POST(URL_PIC)
    Observable<PicBean> picConfig();

    @POST(URL_OFFLINE)
    Observable<Offline> offline();
}


